const Service = require("egg").Service;

class UserService extends Service {
  // 添加学生信息
  async addUser(name, age) {
    try {
      const params = {
        name,
        age,
      };
      const result = await this.app.mysql.insert("user", params);
      const insertSuccess = result.affectedRows === 1;
      if (insertSuccess) {
        return result;
      }
      return null;
    } catch (error) {
      console.log(error);
    }
  }
  // 删除学生信息
  async delStu() {}
  // 更新学生信息
  async updateStu() {}
  // 查询学生信息
  async getUser() {
    const result = await this.app.mysql.select("user");
    return result
  }
}

module.exports = UserService;
